<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="8" :sm="12">
            <a-form-item label="">
              <a-input-group compact>
                <a-select v-model="queryParam.searchField">
                  <a-select-option value="menberUserName"> 姓名 </a-select-option>
                  <a-select-option value="memberDeptName"> 部门 </a-select-option>
                </a-select>
                <a-input-search
                  style="width: 78%"
                  v-model="queryParam.keyword"
                  @search="searchQuery"
                  placeholder="请按照关键字进行搜索"
                />
              </a-input-group>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="8">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<!--              <a-button-group>-->
              <!--                <a-button :type="queryParam.timeFlag == '3' ? 'primary' : ''" @click="handleSearchTime(3)"-->
              <!--                >全部</a-button-->
              <!--                >-->
              <!--              </a-button-group>-->
              <a-button type="primary" @click="handleShow" icon="search" style="margin-left: 30px"
              >高级查询</a-button>
<!--              <a-button-->
<!--                type="primary"-->
<!--                @click="handlePostExportXls('人员成本汇总表')"-->
<!--                icon="download"-->
<!--                style="margin-left: 10px"-->
<!--              >导出</a-button>-->
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
      <a-modal
        :visible="showSearchForm"
        width="70vw"
        :bodyStyle="{ padding: '10px' }"
        title="高级查询"
        @ok="handleToSearch"
        @cancel="showSearchForm = false"
      >
        <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-model-item label="姓名">
                <a-input v-model="queryParam.memberUserName" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="承担部门">
                <a-input v-model="queryParam.memberDeptName" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-modal>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator"></div>
    <div class="container">
      <a-table
        ref="table"
        bordered
        size="middle"
        :scroll="{ x: true }"
        :rowKey="
          (record, index) => {
            return index
          }
        "
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="status" slot-scope="text, record">
          {{ initStatusText(record) }}
        </template>
        <template slot="projectNo" slot-scope="text, record">
          <span style="color: blue" @click="openProjectUrl(record)">{{ text }}</span>
        </template>
        <template slot="endDate" slot-scope="text">
          <span>{{ formatDate(text) }}</span>
        </template>
        <template slot="maxCompletionDate" slot-scope="text, record">
          <span v-if="!record.taskId">
            {{ formatDate(text) }}
          </span>
          <span v-if="record.taskId && record.status == '2' && record.hasSendNotice && record.hasSendNotice != '1'">{{
            formatDate(text)
          }}</span>
        </template>
        <template slot="detail" slot-scope="text, record">
          <a   @click="showEvaluateDetail(record)">明细</a>
        </template>
      </a-table>
      <PersonIWomDetail ref="iWomDetailRef"></PersonIWomDetail>
    </div>
  </a-card>
</template>


<script>
  import { JeecgListMixin } from '@/mixins/JeecgListSearchMixin'
  import {  getAction, postAction } from '@/api/manage'
  import  PersonIWomDetail from '@/views/reportCenter/itAdjustment/modules/PersonIWomDetail'
  import moment from 'moment'
  export default {
    name: 'itAdjustmentList',
    mixins: [JeecgListMixin],
    components: {
      PersonIWomDetail
    },
    data() {
      return {
        description: '信息迭代版本报表',
        /* 勾选导出参数 */
        rowKey: 'id',
        busType: 'itAdjustmentList',
        columns: [
          {
            title: '姓名',
            dataIndex: 'memberRealName',
            key: 'memberRealName',
            width: 90,
            align: 'center',
            scopedSlots: { customRender: 'memberRealName' },
          } ,
          {
            title: '账号',
            dataIndex: 'memberUserName',
            key: 'memberUserName',
            width: 90,
            align: 'center',
            scopedSlots: { customRender: 'memberUserName' },
          },
          {
            title: '部门',
            dataIndex: 'memberDeptName',
            key: 'memberDeptName',
            align: 'center',
            width: 90
          },
          {
            title: '综合评分',
            dataIndex: 'comprehensiveScore',
            key: 'comprehensiveScore',
            align: 'center',
            width: 90
          },
          {
            title: '明细',
            dataIndex: 'detail',
            key: 'detail',
            align: 'center',
            width: 90 ,
            scopedSlots: { customRender: 'detail' },
          }

        ],
        yearList:[] ,
        url: {
          list: '/projectMemberEvaluate/getPersonIWomDetail',
          getCodeInfoList:'/manage/codeInfo/queryByType',
          exportXlsUrl: '/projectBuildManday/personSumExport',
        },
        showSearchForm: false,
        keyword: '',
        labelCol: { span: 8 },
        wrapperCol: { span: 15 },
        queryParam: {
          searchField: 'menberUserName',
          timeFlag: '1',
          startOneTime: null,
          startTweTime: null,
          completeOneTime: null,
          completetTwoTime: null,
        },
        planStartDate:[],
        completeDate:[],
      }
    },
    mounted() {},
    computed: {},
    methods: {
      getDictList(){
        const vm=this;
        getAction(this.url.getCodeInfoList,{type:"年份查找参数"}).then(res=>{
          debugger
          this.yearList = res.result||[];
        })
      },
      initStatusText(record) {
        if (record.status == '1') {
          return '创建中'
        }
        if (record.status == '2' && record.hasSendNotice && record.hasSendNotice != '1') {
          return '已完成'
        } else {
          return '实施中'
        }
      },
      formatDate(date) {
        return date ? moment(date).format('YYYY-MM-DD') : ''
      },
      openProjectUrl(record) {

        console.log('项目id'  , record)
        let urlJump = this.$router.resolve({ path:`/approval?projectBuildId=` + record.id})
        window.open(urlJump.href, '_blank')
      },
      handleToSearch() {
        this.showSearchForm = false
        this.searchQuery()
      },
      searchReset() {
        this.queryParam = {}
        this.queryParam.searchField = '姓名'
        this.queryParam.timeFlag = '1'
        this.queryParam.startOneTime = null
        this.queryParam.startTweTime = null
        this.queryParam.completeOneTime = null
        this.queryParam.completetTwoTime = null
        this.planStartDate = undefined
        this.completeDate = undefined
        this.handleToSearch()
      },
      handleShow() {
        this.getDictList();
        this.showSearchForm = true;
      },
      handleSearchTime(time) {
        if (this.tableLoading) {
          return
        }
        this.queryParam.timeFlag = time
        this.handleToSearch()
      },

      showEvaluateDetail(record){

        this.$refs.iWomDetailRef.showDetail(record.memberUserName)
      },
      showLength(item, len) {
        if (!item || item.length <= len) {
          return item
        }
        return item.substring(0, len) + '...'
      },
      startChange(date ,dateString) {
        console.log(dateString)
        if (dateString && dateString.length > 0) {
          this.queryParam.startOneTime = dateString[0]
          this.queryParam.startTweTime = dateString[0]
        }
      },
      completeChange(date ,dateString) {
        console.log(dateString)
        if (dateString && dateString.length > 0) {
          this.queryParam.completeOneTime = dateString[0]
          this.queryParam.completetTwoTime = dateString[0]
        }
      }
    },
  }
</script>
<style lang="less" scoped>
  @import '~@assets/less/common.less';
  @import '~@assets/less/hte-main.less';
  /deep/ .ant-form-item-label{
    background: white;
  }
  @media (max-width: 1170px) {
    .page-main .container section .list-content > div.flex-num1-box {
      flex-wrap: wrap;
      > div {
        &:nth-child(1),
        &:nth-child(2) {
          width: 48%;
        }
        &:nth-child(3) {
          width: 100%;
          justify-content: flex-start;
          > span {
            margin-right: 20px;
            margin-left: 0;
          }
        }
      }
    }
    .page-main .container section .list-content > div.flex-num2-box {
      display: block;
      margin-top: 0;
    }
  }
</style>